package samples.pinyin.jpinyin;

import com.github.stuxuhai.jpinyin.PinyinException;
import com.github.stuxuhai.jpinyin.PinyinFormat;
import com.github.stuxuhai.jpinyin.PinyinHelper;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Hello world!
 */
public class App {

    public static final Logger LOGGER = LoggerFactory.getLogger(App.class);

    public static void main(String[] args) throws PinyinException {

        String str = "这真是一个神奇的世界啊";

        // 转换成拼音,使用,逗号分隔,拼音带声调
        String strPinyinWithTone = PinyinHelper.convertToPinyinString(str, ",", PinyinFormat.WITH_TONE_MARK);
        LOGGER.info("转换成拼音,使用,逗号分隔,拼音带声调: {}", strPinyinWithTone);

        // 转换成拼音, 使用空格分隔, 拼音不带声调
        String strPinyinWithoutTone = PinyinHelper.convertToPinyinString(str, " ", PinyinFormat.WITHOUT_TONE);
        LOGGER.info("转换成拼音, 使用空格分隔, 不带声调 : {}", strPinyinWithoutTone);

        // 转换成拼音, 不带分隔符, 数字代表声调
        String strPinyinnWithToneNumber = PinyinHelper.convertToPinyinString(str, "", PinyinFormat.WITH_TONE_NUMBER);
        LOGGER.info("转换成拼音, 不带分隔符, 数字代表声调: {}", strPinyinnWithToneNumber);

//        String s = PinyinHelper.convertToPinyinString(str, "", PinyinFormat.WITH_TONE_MARK);

//        LOGGER.info(s);
//        System.out.println("Hello World!");
    }
}
